package com.lxl.todo;


import java.util.Arrays;

/**
 * <h1>三角形的最大周长</h1>
 *
 * @author lxl
 * @since 2025-11-28 10:52
 **/


public class Solution36 {
    public int largestPerimeter(int[] nums) {
        int len = nums.length;
        Arrays.sort(nums);
        for (int i = len - 1; i >= 2 ; --i) {
            if (nums[i - 1] + nums[i - 2] > nums[i]) {
                return nums[i] + nums[i - 1] + nums[i - 2];
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        Solution36 solution36 = new Solution36();
        int[] nums = {3,2,3,4};
        System.out.println(solution36.largestPerimeter(nums));
    }
}
